/*
 * GeoVISTA Center (Penn State, Dept. of Geography)
 * Copyright (c), 2003-2011,  Jin Chen and Alan M. MacEachren, GeoVISTA Center, Penn State University
 * All Rights Researved.
 *
 * This library is developed and distributed for free usage,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * You can redistribute and/or modify it under the terms of the
 * Simplified BSD License
 *
 *
 *
 *
 *
 *
 *
 * Paint a highlighted line
 * @author: jin Chen 
 * @date: Jul 23, 2003$
 * @version: 1.0
 */
package edu.psu.geovista.app.pcp.plot.layer.operation;

/*import edu.psu.geovista.app.pcp.plot.layer.DynamicLayer;
import edu.psu.geovista.app.pcp.plot.layer.TopLayer;*/
import edu.psu.geovista.app.pcp.plot.gui.BasicPcpUI;
import edu.psu.geovista.app.pcp.plot.layer.DataPainter;
import edu.psu.geovista.app.plot.axis.AxisList;
import edu.psu.geovista.app.plot.layer.Layer;

import java.awt.*;

public class HighLightLineOp extends BasicLayerOp {
    Layer layer;

    private int recordId;
    private int x;
    private int y;
    private String name;
    private boolean drawLabel=true;

    public HighLightLineOp(Layer layer) {
        this.layer = layer;
        this.color=Color.red ;
    }

    public void paint(Graphics g) {
        Color old=g.getColor() ;
        if(color==null)
            color=Color.red ;
        g.setColor(this.color);
        //old ((DynamicLayer)this.layer).paintHighLightRecord(g,name,recordId,x,y);

        BasicPcpUI ui = layer.getUi();
        AxisList yaxisList = ui.getPlot().getYaxisList();

        DataPainter painter = ui.getPainter();

        Graphics2D g2d = (Graphics2D)g;
        boolean drawlabel=true;
        if(!isDrawLabel())
              drawlabel=false;
        if(recordId>=0)
            painter.drawAHighlightRecord(g2d,recordId,0,yaxisList.size() -1, drawlabel);
        if(isDrawLabel()&&recordId>=0) {
            //String text=    recordId+""+name
            painter.drawHighlightRecordName(g2d,  recordId+": "+name,x ,y);
        }
        g.setColor(old);
    }

    public void setRecordId(int recordId) {
        this.recordId = recordId;
    }

    public int getX() {
        return x;
    }

    public void setX(int x) {
        this.x = x;
    }

    public int getY() {
        return y;
    }

    public void setY(int y) {
        this.y = y;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public boolean isDrawLabel() {
        return drawLabel;
    }

    public void setDrawLabel(boolean drawLabel) {
        this.drawLabel = drawLabel;
    }
}
